Ext.define('App.reportconfiguration.view.field.ChartConfigurationGridField', {
    extend: 'Extend.form.field.GridField',
    alias: ['widget.ChartConfigurationGridField'],
    border: false,
    roweditable: false,
    sortableColumns: false,
    name: 'chartConfigurations',
    submitFields: ['id', 'title', 'description', 'theme', 'width', 'height', 'stereoscopic', 'pie', {
        column: 'index',
        field: 'idx'
    }, 'axes.id', 'axes.type', 'axes.type', 'axes.position', 'axes.fields', 'axes.title', 'axes.percent', 'axes.idx', 'series.id', 'series.type', 'series.xField', 'series.yFields', 'series.axis', 'series.percent', 'series.stacked', 'series.fill', 'series.idx'],
    columns: [{
        text: 'ID',
        dataIndex: 'id',
        hidden: true,
    }, {
        text: '标题',
        dataIndex: 'title',
        flex: 3
    }, {
        text: '描述',
        dataIndex: 'description',
        flex: 3
    }, {
        text: '宽度(占比)',
        dataIndex: 'width',
        flex: 1
    }, {
        text: '高度(px)',
        dataIndex: 'height',
        flex: 1
    }, {
        text: '3D',
        dataIndex: 'stereoscopic',
        flex: 1,
        renderer: function (v, m, r) {
            return v == true ? '是' : '否';
        }
    }, {
        text: '饼图',
        dataIndex: 'pie',
        flex: 1,
        renderer: function (v, m, r) {
            return v == true ? '是' : '否';
        }
    }],
    addHandler: function () {
        this.editChart()
    },
    listeners: {
        itemdblclick: function ($this, record, item, index, e, eOpts) {
            this.editChart(record)
        },
    },
    editChart: function (chartConfiguration) {
        var me = this;
        var form = Ext.create('App.reportconfiguration.chartconfiguration.view.ChartConfigurationEditor', {
            chartConfiguration: me,
            window: {height: 500, width: 900},
            kpisStore: me.up().down('ReportConfigurationKpiGridField').getStore(),
            model: me.model
        });
        if (!Ext.isEmpty(chartConfiguration)) {
            form.record = chartConfiguration;
            form.loadRecord(chartConfiguration);
        }
        form.show();
    }
})